<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<script src="https://unpkg.com/vue@next"></script>
<div id="app">
    <button v-for="btn in btns" @click="clickCurBtn(btn)" :key="btn">
        {{btn}}
    </button>

    <component v-bind:is="curComponent"></component>
</div>

<script>
    const vueOpt = {
        data(){
            return {
                btns: ['Home', 'Posts', 'Archive'],
                curTab: 'Home'
            }
        },

        methods: {
            clickCurBtn(tab){
                this.curTab = tab;
            }
        },

        computed: {
            curComponent(){
                console.log(this.curTab);
                return 'tab-' + this.curTab.toLowerCase();
            }
        }
    }
    const app = Vue.createApp(vueOpt);

    app.component('tab-home', {
        template: `
            <span>home component</span>
        `
    });

    app.component('tab-posts', {
        template: `
            <span>posts component</span>
        `
    });

    app.component('tab-archive', {
        template: `
            <span>archive component</span>
        `
    })

    app.mount('#app')
</script>
</body>
</html>
